package cn.itlaobing.springmvc.vo;

import java.util.List;

/**
 * 分页对象
 * 
 * @author wq
 *
 */
public class Pageable<T> {

	private Long pageNumber = 1L;// 页码
	private Long pageSize = 2L;// 页大小
	private Long total;// 总条数

	private String baseUrl;// 获取分页信息的baseUrl 不带参数

	private List<T> elements; // 元素集合

	// 获取总页数
	public Long getTotalPage() {
		return total % pageSize == 0 ? total / pageSize : total / pageSize + 1;
	}

	/**
	 * 是否是第一页
	 * 
	 * @return
	 */
	public boolean isFirst() {
		return pageNumber == 1;
	}

	/**
	 * 是否是最后一页
	 * 
	 * @return
	 */
	public boolean isLast() {
		return pageNumber == getTotalPage();
	}

	/**
	 * 是否有下一页
	 * 
	 * @return
	 */
	public boolean isHasNext() {
		return pageNumber < getTotalPage();
	}

	/**
	 * 是否有上一页
	 * 
	 * @return
	 */
	public boolean isHasPrevious() {
		return pageNumber > 1;
	}

	public Long getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(Long pageNumber) {
		this.pageNumber = pageNumber;
	}

	public Long getPageSize() {
		return pageSize;
	}

	public void setPageSize(Long pageSize) {
		this.pageSize = pageSize;
	}

	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}

	public List<T> getElements() {
		return elements;
	}

	public void setElements(List<T> elements) {
		this.elements = elements;
	}

	public void setBaseUrl(String baseUrl) {
		this.baseUrl = baseUrl;
	}
	



}
